{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "093cbf2c",
   "metadata": {},
   "source": [
    "## 1. CandleRule规则总览\n",
    "\n",
    "from binance_interface.app.candle_server import CandleRule\n",
    "\n",
    "|参数|类型|默认值|说明|\n",
    "|:---|:---|:---|:---|\n",
    "|SERVER_WEIGHT|float, int|0.75|服务占用权重上限的比例 现货交易权重上限1200 合约交易权重上限2400|\n",
    "|SYMBOLS|str,list|'all'|收集的产品 all表示全部正在交易的产品|\n",
    "|SYMBOLS_FILTER|list|[]|过滤的产品|\n",
    "|SYMBOL_CONTAINS|str|''|产品名称中需要包含的内容|\n",
    "|SYMBOL_ENDSWITH|str|''|产品名称必须以何内容结尾|\n",
    "|BAR|str|binance_interface.binace_lite.BINANCE_DEFAULT_BAR|时间颗粒度|\n",
    "|TIMEZONE|str|binance_interface.binace_lite.BINANCE_TIMEZONE|时区|\n",
    "|CANDLE_DIR|str|binance_interface.binace_lite.BINANCE_CANDLE_DATE_BASE_DIR|以天为单位的数据存储路径|\n",
    "|LENGTH|int|1440 * 2|candle_map 缓存K线数据长度（实时K线服务）|\n",
    "|UPDATE_INTERVAL_SECONDS|int|3|candle_map 更新时间间隔（秒）（实时K线服务）|\n",
    "|CACHE_DELAY_SECONDS|int, None|60 * 60|candle_map 保存缓存文件时间间隔（秒） None：不保存缓存（实时K线服务）|\n",
    "|CACHE_DIR|str|'./BINANCE_CACHE'|缓存数据路径（实时K线服务）|\n",
    "|LOCAL_CANDLE_DAYS|int|2|服务启动 需维护本地多少天的历史K线数据（实时K线服务）|\n",
    "|DOWNLOAD_TIME|str, None|'00:10:00'|每日下载昨日历史K线数据的时刻 格式：%H:%M:%S None表示不下载（每日定时下载K线中使用）|\n",
    "|KEY|str, None|None|KEY 通常无需填写|\n",
    "|SECRET|str, None|None|SECRET 通常无需填写|\n",
    "|LOG_DIRPATH|str|'./BINANCE_CANDLE_SERVER_LOG_DATA'|日志文件夹|\n",
    "|LOG_FILE_LEVEL|str|'INFO'|日志文件级别|\n",
    "|LOG_CONSOLE_LEVEL|str|'DEBUG'|日志打印级别|"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb7eee4a",
   "metadata": {},
   "source": [
    "其中与\"下载历史K线功能\"重要相关配置为：\n",
    "\n",
    "|参数|类型|默认值|说明|\n",
    "|:---|:---|:---|:---|\n",
    "|**SERVER_WEIGHT**|float, int|0.75|服务占用权重上限的比例 现货交易权重上限1200 合约交易权重上限2400|\n",
    "|**SYMBOLS**|str,list|'all'|收集的产品 all表示全部正在交易的产品|\n",
    "|**SYMBOLS_FILTER**|list|[]|过滤的产品|\n",
    "|**SYMBOL_CONTAINS**|str|''|产品名称中需要包含的内容|\n",
    "|**SYMBOL_ENDSWITH**|str|''|产品名称必须以何内容结尾|\n",
    "|**BAR**|str|binance_interface.binace_lite.BINANCE_DEFAULT_BAR|时间颗粒度|\n",
    "|**TIMEZONE**|str|binance_interface.binace_lite.BINANCE_TIMEZONE|时区|\n",
    "|**CANDLE_DIR**|str|binance_interface.binace_lite.BINANCE_CANDLE_DATE_BASE_DIR|以天为单位的数据存储路径|"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f72ceca2",
   "metadata": {},
   "source": [
    "## 2. 以日期为单位下载历史K线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f399ab29",
   "metadata": {},
   "outputs": [],
   "source": [
    "from binance_interface.app.candle_server import CandleRule,CandleServer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "61daf553",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-01-26 01:05:02,672 [INFO] DOWNLOAD BTCUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:03,682 [INFO] DOWNLOAD BTCUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:04,654 [INFO] DOWNLOAD BTCUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:05,642 [INFO] DOWNLOAD ETHUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:06,563 [INFO] DOWNLOAD ETHUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:07,493 [INFO] DOWNLOAD ETHUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:08,373 [INFO] DOWNLOAD LINKUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:09,202 [INFO] DOWNLOAD BNBUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:10,041 [INFO] DOWNLOAD TRXUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:10,951 [INFO] DOWNLOAD DOTUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:11,771 [INFO] DOWNLOAD ADAUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:12,812 [INFO] DOWNLOAD EOSUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:13,761 [INFO] DOWNLOAD LTCUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:14,640 [INFO] DOWNLOAD BCHUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:15,402 [INFO] DOWNLOAD XRPUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:16,173 [INFO] DOWNLOAD ETCUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:16,942 [INFO] DOWNLOAD FILUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:18,111 [INFO] DOWNLOAD EGLDUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:18,933 [INFO] DOWNLOAD DOGEUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:19,703 [INFO] DOWNLOAD UNIUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:20,392 [INFO] DOWNLOAD THETAUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:21,242 [INFO] DOWNLOAD XLMUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:22,074 [INFO] DOWNLOAD SOLUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:22,832 [INFO] DOWNLOAD FTMUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:23,549 [INFO] DOWNLOAD SANDUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:24,242 [INFO] DOWNLOAD MANAUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:25,022 [INFO] DOWNLOAD AVAXUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:25,894 [INFO] DOWNLOAD MATICUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:26,691 [INFO] DOWNLOAD NEARUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:27,402 [INFO] DOWNLOAD ATOMUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:28,199 [INFO] DOWNLOAD AAVEUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:28,992 [INFO] DOWNLOAD AXSUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:29,819 [INFO] DOWNLOAD ROSEUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:30,450 [INFO] DOWNLOAD XTZUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:31,100 [INFO] DOWNLOAD ICXUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:31,834 [INFO] DOWNLOAD ALGOUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:32,611 [INFO] DOWNLOAD RUNEUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:33,270 [INFO] DOWNLOAD APEUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:34,002 [INFO] DOWNLOAD KNCUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:34,669 [INFO] DOWNLOAD XMRUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:35,371 [INFO] DOWNLOAD GMTUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:36,184 [INFO] DOWNLOAD OPUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:36,900 [INFO] DOWNLOAD ENSUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:37,480 [INFO] DOWNLOAD CHZUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:38,190 [INFO] DOWNLOAD APTUSD_PERP 1m  02/01/2024\n",
      "2024-01-26 01:05:38,782 [INFO] DOWNLOAD ADAUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:39,479 [INFO] DOWNLOAD LINKUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:40,199 [INFO] DOWNLOAD BCHUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:40,927 [INFO] DOWNLOAD DOTUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:41,645 [INFO] DOWNLOAD XRPUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:42,389 [INFO] DOWNLOAD LTCUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:43,102 [INFO] DOWNLOAD BNBUSD_240329 1m  02/01/2024\n",
      "2024-01-26 01:05:43,820 [INFO] DOWNLOAD ADAUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:44,450 [INFO] DOWNLOAD LINKUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:45,170 [INFO] DOWNLOAD BCHUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:45,811 [INFO] DOWNLOAD DOTUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:46,439 [INFO] DOWNLOAD XRPUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:47,129 [INFO] DOWNLOAD LTCUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:47,767 [INFO] DOWNLOAD BNBUSD_240628 1m  02/01/2024\n",
      "2024-01-26 01:05:47,768 [INFO] COMPLETE DOWNLOAD 02/01/2024 (ALL:59 SKIP:0 SUC:59 WARN:0 ERROR:0)\n",
      "2024-01-26 01:05:48,951 [INFO] DOWNLOAD BTCUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:49,771 [INFO] DOWNLOAD BTCUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:05:50,413 [INFO] DOWNLOAD BTCUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:05:51,169 [INFO] DOWNLOAD ETHUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:51,889 [INFO] DOWNLOAD ETHUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:05:52,536 [INFO] DOWNLOAD ETHUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:05:53,231 [INFO] DOWNLOAD LINKUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:53,964 [INFO] DOWNLOAD BNBUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:54,600 [INFO] DOWNLOAD TRXUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:55,402 [INFO] DOWNLOAD DOTUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:56,131 [INFO] DOWNLOAD ADAUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:56,801 [INFO] DOWNLOAD EOSUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:57,579 [INFO] DOWNLOAD LTCUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:58,307 [INFO] DOWNLOAD BCHUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:59,027 [INFO] DOWNLOAD XRPUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:05:59,749 [INFO] DOWNLOAD ETCUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:00,480 [INFO] DOWNLOAD FILUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:01,302 [INFO] DOWNLOAD EGLDUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:02,008 [INFO] DOWNLOAD DOGEUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:02,659 [INFO] DOWNLOAD UNIUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:03,319 [INFO] DOWNLOAD THETAUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:04,101 [INFO] DOWNLOAD XLMUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:04,921 [INFO] DOWNLOAD SOLUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:05,591 [INFO] DOWNLOAD FTMUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:06,308 [INFO] DOWNLOAD SANDUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:07,098 [INFO] DOWNLOAD MANAUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:07,812 [INFO] DOWNLOAD AVAXUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:08,550 [INFO] DOWNLOAD MATICUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:09,270 [INFO] DOWNLOAD NEARUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:10,029 [INFO] DOWNLOAD ATOMUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:10,830 [INFO] DOWNLOAD AAVEUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:11,712 [INFO] DOWNLOAD AXSUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:12,471 [INFO] DOWNLOAD ROSEUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:13,387 [INFO] DOWNLOAD XTZUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:14,336 [INFO] DOWNLOAD ICXUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:15,057 [INFO] DOWNLOAD ALGOUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:15,830 [INFO] DOWNLOAD RUNEUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:16,455 [INFO] DOWNLOAD APEUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:17,127 [INFO] DOWNLOAD KNCUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:17,806 [INFO] DOWNLOAD XMRUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:18,558 [INFO] DOWNLOAD GMTUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:19,300 [INFO] DOWNLOAD OPUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:20,051 [INFO] DOWNLOAD ENSUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:20,689 [INFO] DOWNLOAD CHZUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:21,530 [INFO] DOWNLOAD APTUSD_PERP 1m  01/01/2024\n",
      "2024-01-26 01:06:22,197 [INFO] DOWNLOAD ADAUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:22,864 [INFO] DOWNLOAD LINKUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:23,497 [INFO] DOWNLOAD BCHUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:24,097 [INFO] DOWNLOAD DOTUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:24,663 [INFO] DOWNLOAD XRPUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:25,333 [INFO] DOWNLOAD LTCUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:25,920 [INFO] DOWNLOAD BNBUSD_240329 1m  01/01/2024\n",
      "2024-01-26 01:06:26,497 [INFO] DOWNLOAD ADAUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:27,098 [INFO] DOWNLOAD LINKUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:27,715 [INFO] DOWNLOAD BCHUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:28,284 [INFO] DOWNLOAD DOTUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:28,980 [INFO] DOWNLOAD XRPUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:29,587 [INFO] DOWNLOAD LTCUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:30,169 [INFO] DOWNLOAD BNBUSD_240628 1m  01/01/2024\n",
      "2024-01-26 01:06:30,171 [INFO] COMPLETE DOWNLOAD 01/01/2024 (ALL:59 SKIP:0 SUC:59 WARN:0 ERROR:0)\n"
     ]
    }
   ],
   "source": [
    "# 币币交易：SPOT；U本位合约：UM；币本位合约：CM\n",
    "instType = 'CM'\n",
    "# 永续合约，默认规则\n",
    "candleServer = CandleServer(\n",
    "    instType=instType,\n",
    "    rule=CandleRule,\n",
    "    # 使用http和https代理，proxies={'http':'xxxxx','https:':'xxxxx'}，通requests中的proxies参数规则相同\n",
    "    proxies={},\n",
    "    # 转发：需搭建转发服务器，可参考：https://github.com/pyted/binance_resender\n",
    "    proxy_host=None,\n",
    ")\n",
    "# 下载2023-01-01 ~ 2023-01-02 全部instType的历史K线\n",
    "candleServer.download_candles_by_date(\n",
    "    start='2024-01-01',\n",
    "    end='2024-01-02',\n",
    "    replace=True,  # 如果历史K线存在则替换\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f19ed38",
   "metadata": {},
   "source": [
    "## 3. 以日期为单位读取历史K线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "52929144",
   "metadata": {},
   "outputs": [],
   "source": [
    "from binance_interface import BinanceLite"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d51ec352",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.67254920e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "        2.68840000e+01, 4.44064535e+05, 0.00000000e+00],\n",
       "       [1.67254926e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "        1.87850000e+01, 3.10286873e+05, 0.00000000e+00],\n",
       "       [1.67254932e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "        1.90070000e+01, 3.13953825e+05, 0.00000000e+00],\n",
       "       ...,\n",
       "       [1.67272182e+12, 1.66795000e+04, 1.66795000e+04, ...,\n",
       "        1.13370000e+01, 1.89095492e+05, 0.00000000e+00],\n",
       "       [1.67272188e+12, 1.66794000e+04, 1.66795000e+04, ...,\n",
       "        6.51300000e+00, 1.08632742e+05, 0.00000000e+00],\n",
       "       [1.67272194e+12, 1.66786000e+04, 1.66827000e+04, ...,\n",
       "        2.85580000e+01, 4.76342266e+05, 0.00000000e+00]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "binanceLite = BinanceLite()\n",
    "# 读取指定产品的历史K线\n",
    "candle = binanceLite.load_candle_by_date(\n",
    "    instType='UM',\n",
    "    symbol='BTCUSDT',\n",
    "    start='2023-01-01',\n",
    "    end='2023-01-02',\n",
    "    bar='1m',\n",
    "    timezone='America/New_York',\n",
    ")\n",
    "candle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0e61ff43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BTCUSDT': array([[1.67254920e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "         2.68840000e+01, 4.44064535e+05, 0.00000000e+00],\n",
       "        [1.67254926e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "         1.87850000e+01, 3.10286873e+05, 0.00000000e+00],\n",
       "        [1.67254932e+12, 1.65178000e+04, 1.65178000e+04, ...,\n",
       "         1.90070000e+01, 3.13953825e+05, 0.00000000e+00],\n",
       "        ...,\n",
       "        [1.67272182e+12, 1.66795000e+04, 1.66795000e+04, ...,\n",
       "         1.13370000e+01, 1.89095492e+05, 0.00000000e+00],\n",
       "        [1.67272188e+12, 1.66794000e+04, 1.66795000e+04, ...,\n",
       "         6.51300000e+00, 1.08632742e+05, 0.00000000e+00],\n",
       "        [1.67272194e+12, 1.66786000e+04, 1.66827000e+04, ...,\n",
       "         2.85580000e+01, 4.76342266e+05, 0.00000000e+00]]),\n",
       " 'ETHUSDT': array([[1.67254920e+12, 1.19309000e+03, 1.19310000e+03, ...,\n",
       "         2.10605000e+02, 2.51240811e+05, 0.00000000e+00],\n",
       "        [1.67254926e+12, 1.19300000e+03, 1.19308000e+03, ...,\n",
       "         3.23947000e+02, 3.86465582e+05, 0.00000000e+00],\n",
       "        [1.67254932e+12, 1.19308000e+03, 1.19349000e+03, ...,\n",
       "         7.62142000e+02, 9.09460891e+05, 0.00000000e+00],\n",
       "        ...,\n",
       "        [1.67272182e+12, 1.21342000e+03, 1.21353000e+03, ...,\n",
       "         4.66782000e+02, 5.66439193e+05, 0.00000000e+00],\n",
       "        [1.67272188e+12, 1.21341000e+03, 1.21342000e+03, ...,\n",
       "         7.99960000e+01, 9.70552671e+04, 0.00000000e+00],\n",
       "        [1.67272194e+12, 1.21323000e+03, 1.21400000e+03, ...,\n",
       "         1.71236200e+03, 2.07784055e+06, 0.00000000e+00]])}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取多个产品的历史K线字典\n",
    "candle_map = binanceLite.load_candle_map_by_date(\n",
    "    instType='UM',\n",
    "    symbols=['BTCUSDT', 'ETHUSDT'],  # []表示全部的产品\n",
    "    start='2023-01-01',\n",
    "    end='2023-01-02',\n",
    "    bar='1m',\n",
    "    timezone='America/New_York',\n",
    ")\n",
    "\n",
    "candle_map"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}